package com.obtk.shilipai.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.obtk.shilipai.entity.Appraise;
import com.obtk.shilipai.entity.Order;
import com.obtk.shilipai.service.AppraiseService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/appraise")
public class AppraiseController {
    @Autowired
    private AppraiseService appraiseService;
    @RequestMapping("/getAppraiseByAll")
    public String getAppraiseByAll(@RequestParam(required = false, defaultValue = "1") int pageNo,
                                   @RequestParam(required = false, defaultValue = "10") int pageSize,
                                   Model model, Integer shopId){
        PageHelper.startPage(pageNo, pageSize);
        List<Appraise> appraise = appraiseService.getAppraiseByAll(shopId);
        PageInfo<Appraise> page = new PageInfo<Appraise>(appraise);
        model.addAttribute("page",page);
        model.addAttribute("appraise",appraise);
        model.addAttribute("shopId",shopId);
        System.out.println(appraise);
        return "appraise/list";
    }
}
